package ciyuan.Player.Skill.Passive;

import ciyuan.Effect.Effects;
import ciyuan.Player.Skill.MySkill;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ArrowEntity;
import net.minecraft.item.BowItem;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Hand;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;

public class WeaknessAnalysis extends MySkill {
    @Override
    public void keyDown(PlayerEntity playerEntity) {

    }

    @Override
    public String getSkillCastName() {
        return "WeaknessAnalysis";
    }

    @Override
    public ITextComponent getSkillDescription() {
        return new TranslationTextComponent("ciyuan.skill.desc.30");
    }

    @Override
    public ITextComponent getSkillName() {
        return new TranslationTextComponent("ciyuan.skill.name.30");
    }

    public static void onCrital(Entity from, DamageSource damageSource) {
        if (from instanceof PlayerEntity){
            PlayerEntity playerEntity = (PlayerEntity) from;
            if (!playerEntity.getItemInHand(Hand.MAIN_HAND).isEmpty()) {
                if (playerEntity.getItemInHand(Hand.MAIN_HAND).getItem() instanceof BowItem) {
                    if (damageSource.getDirectEntity()!=null) {
                        if (damageSource.getDirectEntity() instanceof ArrowEntity) {
                            playerEntity.addEffect(new EffectInstance(Effects.weakness_analysis,20,1));
                        }
                    }
                }
            }
        }


    }
}
